<?php
class Training_Form_Decorator3 extends Zend_Form{
	
	public function init(){
		$decoratorsForm = array(			
								'FormElements',
								//'HtmlTag',
								//array('HtmlTag', array('tag' => 'table')),
								 array('HtmlTag', array('class'=>'formLements',
								 						'tag' => 'div',
								 						)),	
								'Form',															
								);
		$this->addPrefixPath('My_Decorator',
                        			'My/Decorator/',
                        				'decorator');
		
		//Zendvn_Form_Decorator_Element
		
		$this->addPrefixPath('Zendvn_Form_Decorator',
                        			'Zendvn/Form/Decorator/',
                        				'decorator');
		$this->setMethod('post')
			->setEnctype('multipart/form-data')
			->setAction('')
			->setName('appForm')
			->setDecorators($decoratorsForm);	
		
	//$textbox->getView()->formLabel($textbox->getName(), 'abc')
		//<label for="textboxABC">abc</label>
		
		//=================Zend_Form_Element_Text================
		$username = new Zend_Form_Element_Text('username'); //$name
		$username->setLabel('Username')
				->setDescription('Nhap username cua ban')
				->setRequired()
				->setDecorators(array('Element'));

		$password = new Zend_Form_Element_Password('password'); //$name
		$password->setLabel('Password')
				->setDescription('Nhap password cua ban')
				->setRequired()
				->setDecorators(array('Element'));
		
		$avatar = new Zend_Form_Element_File('avatar'); //$name
		$avatar->setLabel('Avatar')
				->setDescription('Nhap avatar cua ban')
				->setRequired()
				->setDecorators(array('File',array('ViewScript',array('viewScript' => '_element.php','placement' => false))));
		
		$txtbox = new Zend_Form_Element_Text('txtbox'); //$name
		$txtbox->setLabel('txtbox')
				->setDescription('Nhap username cua ban')
				->setRequired()
				->setDecorators(array(array('ViewScript',array('viewScript' => '_element1.php','placement' => false))));
					
		$sumbit = new Zend_Form_Element_Submit('submit');
		$sumbit->setValue('Save now')
			 ->setAttrib('class','input');
			 
		$this->addElements(array($username,$password,$avatar,$txtbox, $sumbit));
		
	}
}